package JZOffer;

import com.sun.source.tree.Tree;

import java.util.ArrayList;

public class _25_ {
    class Solution {
        TreeNode leftHead = null;
        TreeNode rightHead = null;
        public TreeNode Convert(TreeNode pRootOfTree) {
            if (pRootOfTree == null) return null;
            Convert(pRootOfTree.left);
            if (rightHead == null) {
                leftHead = rightHead = pRootOfTree;
            }else {
                rightHead.right = pRootOfTree;
                pRootOfTree.left = rightHead;
                rightHead = pRootOfTree;
            }

            Convert(pRootOfTree.right);

            return leftHead;
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _25_ c = new _25_();
        _25_.Solution s = c.getSolution();
        TreeNode L1 = new TreeNode(3);
        TreeNode L2 = new TreeNode(4);
        TreeNode L3 = new TreeNode(10);
        TreeNode L4 = new TreeNode(6);
        TreeNode L5 = new TreeNode(7);
        L1.left = L2;
        L1.right = L3;
        L2.left = L4;
        L2.right = L5;
//        System.out.println(L1,7);
        
    }
}
